package com.ycd.gis.controller;

import java.util.List;

import com.ycd.gis.domain.GisMarker;
import com.ycd.gis.service.IGisMarkerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ycd.common.annotation.Log;
import com.ycd.common.enums.BusinessType;
import com.ycd.gis.domain.GisMarkerRecord;
import com.ycd.gis.service.IGisMarkerRecordService;
import com.ycd.common.core.controller.BaseController;
import com.ycd.common.core.domain.AjaxResult;
import com.ycd.common.utils.poi.ExcelUtil;
import com.ycd.common.core.page.TableDataInfo;

/**
 * 标记记录Controller
 * 
 * @author ruoyi
 * @date 2021-12-02
 */
@Controller
@RequestMapping("/gis/markerrecord")
public class GisMarkerRecordController extends BaseController
{
    private String prefix = "gis/markerrecord";

    @Autowired
    private IGisMarkerRecordService gisMarkerRecordService;
    @Autowired
    private IGisMarkerService gisMarkerService;

    @RequiresPermissions("com.ycd.gis:markerrecord:view")
    @GetMapping()
    public String markerrecord()
    {
        return prefix + "/markerrecord";
    }

    /**
     * 查询标记记录列表
     */
//    @RequiresPermissions("com.ycd.gis:markerrecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(GisMarkerRecord gisMarkerRecord)
    {
        startPage();
        List<GisMarkerRecord> list = gisMarkerRecordService.selectGisMarkerRecordList(gisMarkerRecord);
        return getDataTable(list);
    }

    /**
     * 导出标记记录列表
     */
    @RequiresPermissions("com.ycd.gis:markerrecord:export")
    @Log(title = "标记记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GisMarkerRecord gisMarkerRecord)
    {
        List<GisMarkerRecord> list = gisMarkerRecordService.selectGisMarkerRecordList(gisMarkerRecord);
        ExcelUtil<GisMarkerRecord> util = new ExcelUtil<GisMarkerRecord>(GisMarkerRecord.class);
        return util.exportExcel(list, "标记记录数据");
    }

    /**
     * 新增标记记录
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        List<GisMarker> gisMarkerList = gisMarkerService.selectGisMarkerList(new GisMarker());
        mmap.put("gisMarkerList",gisMarkerList);
        return prefix + "/add";
    }

    /**
     * 新增保存标记记录
     */
    @RequiresPermissions("com.ycd.gis:markerrecord:add")
    @Log(title = "标记记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GisMarkerRecord gisMarkerRecord)
    {
        return toAjax(gisMarkerRecordService.insertGisMarkerRecord(gisMarkerRecord));
    }

    /**
     * 修改标记记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        List<GisMarker> gisMarkerList = gisMarkerService.selectGisMarkerList(new GisMarker());
        mmap.put("gisMarkerList",gisMarkerList);
        GisMarkerRecord gisMarkerRecord = gisMarkerRecordService.selectGisMarkerRecordById(id);
        mmap.put("gisMarkerRecord", gisMarkerRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存标记记录
     */
    @RequiresPermissions("com.ycd.gis:markerrecord:edit")
    @Log(title = "标记记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(GisMarkerRecord gisMarkerRecord)
    {
        return toAjax(gisMarkerRecordService.updateGisMarkerRecord(gisMarkerRecord));
    }

    /**
     * 删除标记记录
     */
    @RequiresPermissions("com.ycd.gis:markerrecord:remove")
    @Log(title = "标记记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gisMarkerRecordService.deleteGisMarkerRecordByIds(ids));
    }
}
